﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.world.vos.areas {
    import flash.geom.*;
    import flash.utils.*;
    import net.wooga.pets.models.world.vos.*;
    import __AS3__.vec.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;

    public class RoomVO extends AbstractAreaVO implements IAccessible, ICustomizable, IRoom {

        protected var _positions:Dictionary;
        protected var _machine:IMachine;
        private var _doctorId:String;
        private var _slotId:int;
        private var _machinePath:String;
        private var _machineView:Class;
        private var _reservedBy:String;
        private var _isReservable:Boolean;
        private var _hasFacade:Boolean;
        private var _items:Vector.<RewardItemVO>;
        private var _pendingDoctor:Object;
        private var _rewardStartPos:Point;
        private var _rewardLandingXStart:int;
        private var _rewardLandingXEnd:int;

        public function RoomVO(_arg1:Object){
            super(_arg1);
            this._slotId = int(_arg1[ProtocolConstants.SLOT_ID]);
            this.checkReservation(_arg1.pets);
            this._items = new Vector.<RewardItemVO>();
        }
        private function checkReservation(_arg1:Array):void{
            var _local2:Object;
            for each (_local2 in _arg1) {
                if (_local2.workflow_state != GameConstants.STATE_DOCTOR){
                    this.reservedBy = _local2.id;
                    break;
                };
            };
        }
        public function get slotId():int{
            return (this._slotId);
        }
        public function get state():String{
            return (this._machine.state);
        }
        public function get machineView():Class{
            return (this._machineView);
        }
        public function get machinePath():String{
            return (this._machinePath);
        }
        public function get rewardStartPos():Point{
            return (this._rewardStartPos);
        }
        public function get rewardLandingXStart():int{
            return (this._rewardLandingXStart);
        }
        public function get rewardLandingXEnd():int{
            return (this._rewardLandingXEnd);
        }
        public function get reservedBy():String{
            return ((this._isReservable) ? this._reservedBy : null);
        }
        public function set reservedBy(_arg1:String):void{
            this._reservedBy = _arg1;
        }
        public function set config(_arg1:RoomConfigVO):void{
            this._hasFacade = _arg1.hasFacade;
            this._positions = _arg1.positions;
            this._isReservable = _arg1.isReservable;
            this._machinePath = _arg1.machinePath;
            this._machineView = _arg1.machineView;
            this._rewardStartPos = _arg1.rewardStartPos;
            this._rewardLandingXStart = _arg1.rewardLandingXStart;
            this._rewardLandingXEnd = _arg1.rewardLandingXEnd;
        }
        public function set machine(_arg1:IMachine):void{
            this._machine = _arg1;
            this.addActor(this._machine);
        }
        public function get machine():IMachine{
            return (this._machine);
        }
        public function get isFree():Boolean{
            return (((!(this._machine)) || (this._machine.isFree)));
        }
        public function get hasFacade():Boolean{
            return (this._hasFacade);
        }
        public function getTargetPositionOf(_arg1:String, _arg2:Number=0):Point{
            var _local3:Point = (((this._positions[_arg1]) || (this._positions[GameConstants.STATE_PATIENT])) as Point);
            _local3 = ((_local3) || (this.randomPosition));
            _local3.x = ((_arg2) || (_local3.x));
            return (_local3);
        }
        protected function get randomPosition():Point{
            var _local1:int = (GameConstants.ROOM_WIDTH * 0.4);
            var _local2:int = (GameConstants.ROOM_WIDTH * 0.2);
            var _local3:int = ((GameConstants.ROOM_WIDTH - _local1) - _local2);
            var _local4:int = ((_local3 * Math.random()) + _local1);
            var _local5:int = (GameConstants.ROOM_HEIGHT - GameConstants.PATIENT_BOTTOM_OFFSET);
            return (new Point(_local4, _local5));
        }
        public function handlePatient(_arg1:ITreatable):void{
            if (this._machine){
                this._machine.handlePatient(_arg1);
            };
        }
        public function handleBaby(_arg1:IBaby, _arg2:Boolean):void{
            if (this._machine){
                this._machine.handleBaby(_arg1, _arg2);
            };
        }
        override public function addActor(_arg1:IActing):void{
            super.addActor(_arg1);
            if ((_arg1 is ITreating)){
                this._doctorId = _arg1.id;
                this._machine.operator = this.doctor;
            };
        }
        public function get patientIdList():Vector.<String>{
            return (this.patientsIdList);
        }
        public function get doctor():ITreating{
            return ((getActor(this._doctorId) as ITreating));
        }
        public function get rewardItems():Vector.<RewardItemVO>{
            return (this._items);
        }
        public function set rewardItems(_arg1:Vector.<RewardItemVO>):void{
            this._items = _arg1;
        }
        public function get pendingRewardItems():Vector.<RewardItemVO>{
            var _local2:RewardItemVO;
            var _local1:Vector.<RewardItemVO> = new Vector.<RewardItemVO>();
            for each (_local2 in this.rewardItems) {
                if (_local2.alreadyCollected){
                    _local1.push(_local2);
                };
            };
            return (_local1);
        }
        public function set pendingDoctor(_arg1:Object):void{
            this._pendingDoctor = _arg1;
        }
        public function get pendingDoctor():Object{
            return (this._pendingDoctor);
        }

    }
}//package net.wooga.pets.models.world.vos.areas 
